<template>
    <!-- 
    <b-modal ref="my-modal" hide-footer title="Using Component Methods">
     <div class="d-block text-center">
       <h3>Hello From My Modal!</h3>
     </div>
     <b-button class="mt-3" variant="outline-danger" block @click="hideModal">Close Me</b-button>
     <b-button class="mt-2" variant="outline-warning" block @click="toggleModal">Toggle Me</b-button>
   </b-modal> 
    -->
    <!--
        body-class="modalStyle" 表示样式
        size="lg" 表示模态窗口大小 xl,lg,sm,full
        hide-footer 表示隐藏底部按钮
        hide-header 表示隐藏头部内容
        no-close-on-backdrop 表示鼠标点击背景不可关闭
        hide-header-close 表示隐藏头部关闭按钮
        centered 居中
        ok-title=“确定” 
        cancel-title=取消
        @ok="handleOk" 
        @cancel="handleCancel"
        scrollable 滚动条
        hide-backdrop 隐藏背景
        wrapClassName="ant-modal-cust-warp" 
        style="top:5%;height: 85%;overflow-y: hidden" 样式
    -->
    <b-modal ref="my-modal" title="组成员" hide-footer scrollable no-close-on-backdrop>
        <div class="d-block text-center" id="tableAcgBody">
            <!--分页组件-->
            <el-table style="width: 100%" stripe border @selection-change="handleSelectionChange" highlight-current-row
                :data="dataList">
                <!-- 复选框 -->
                <el-table-column type="selection" width="40"></el-table-column>
                <el-table-column label="序号" min-width="50">
                    <template slot-scope="scope">
                        {{ scope.$index + 1 }}
                    </template>
                </el-table-column>
                <el-table-column align="left" prop="name" show-overflow-tooltip label="名称"></el-table-column>
                <el-table-column align="left" :formatter="formatType" show-overflow-tooltip label="类型"></el-table-column>
                <el-table-column align="left" show-overflow-tooltip label="操作" min-width="50">
                    <template slot-scope="scope">
                        <a href="javascript:;" @click="doSelectUser(scope.row)" class="btn btn-sm btn-clean btn-icon"
                            v-if="scope.row.type == 'candidate'">
                            <span class="svg-icon svg-icon-primary svg-icon-2x">
                                <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
                                    width="24px" height="24px" viewBox="0 0 24 24" version="1.1">
                                    <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                                        <rect x="0" y="0" width="24" height="24"></rect>
                                        <path
                                            d="M6,8 L6,20.5 C6,21.3284271 6.67157288,22 7.5,22 L16.5,22 C17.3284271,22 18,21.3284271 18,20.5 L18,8 L6,8 Z"
                                            fill="#000000" fill-rule="nonzero"></path>
                                        <path
                                            d="M14,4.5 L14,4 C14,3.44771525 13.5522847,3 13,3 L11,3 C10.4477153,3 10,3.44771525 10,
                                                4 L10,4.5 L5.5,4.5 C5.22385763,4.5 5,4.72385763 5,5 L5,5.5 C5,5.77614237 5.22385763,6 5.5,6 L18.5,
                                                6 C18.7761424,6 19,5.77614237 19,5.5 L19,5 C19,4.72385763 18.7761424,4.5 18.5,4.5 L14,4.5 Z"
                                            fill="#000000" opacity="0.3">
                                        </path>
                                    </g>
                                </svg>
                            </span>
                        </a>
                    </template>
                </el-table-column>

            </el-table>
        </div>
        <template slot="modal-footer">
            <!--自定义按钮-->
        </template>
    </b-modal>
</template>
<script>
import apiUtil from "@/core/util/apiUtil.js";
import { handleNotify, handleAlert, handleConfirm, showWating, closeWating, dateformat } from "@/core/util/jehcUtil.js";
export default {
    data() {
        return {
            taskId: "",
            dataList: [],
            sels: [], //当前选框选中的值
        }
    },
    components: {

    },
    watch: {
    },
    mounted() {

    },
    methods: {
        showModal(row) {
            this.$refs['my-modal'].show();
            this.taskId = row.taskId;
            this.initList();
        },
        hideModal() {
            this.$refs['my-modal'].hide()
        },
        toggleModal() {
            // 当模态已隐藏时，我们传递要返回焦点的按钮的ID
            this.$refs['my-modal'].toggle('#toggle-btn')
        },
        initList() {
            showWating({ renderBody: "tableAcgBody" });
            var params = { taskId: this.taskId };
            apiUtil.get(process.env.VUE_APP_WORKFLOW_API + "/lcTask/findGroupUsers", params).then(({ data }) => {
                this.dataList = data.data;//给结果集赋值
            });
        },
        handleSelectionChange(sels) {//获取选中的值
            this.sels = sels;
        },
        search() {
            this.initList();          // 按新的pageNo和pageSize进行查询
        },
        formatType(row) {
            let data = row.type;
            if (data == 'candidate') {
                return "候选人";
            }
            if (data == 'candidateGroup') {
                return "组";
            }
            if (data == 'assignee') {
                return "经办人";
            }
            return "缺省";
        },
        doSelectUser(row) {
            this.hideModal();//关闭窗体
            this.$emit("change", row);//组件传值，即向父级模态框中传递值，采用change方式，目标刷新主列表使用      
        },
    }
}
</script>